import { type HttpHandler, HttpResponse, http } from 'msw'
import { auth } from './user'

export function createClassHandler(prefix: string): HttpHandler[] {
  const getPath = (path = '') => `${prefix}/classes${path}`

  return [
    http.get(getPath(''), async ({ request }) => {
      const authError = auth(request)
      if (authError !== undefined) {
        return authError
      }

      return HttpResponse.json({})
    })
  ]
}
